Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Collections.​Generic.​Comparer<​T>
Assembly: System.Collections
Inheritance: object → Comparer
Implemented Interfaces
Provides a base class for implementations of the <see cref="T:System.Collections.Generic.IComparer`1" /> generic interface.
Properties
public static
Comparer<​T>
Default
Returns a default sort-order comparer for the type specified by the generic argument.
Methods
public
int
Compare​(T x,
T y)
When overridden in a derived class, performs a comparison of two objects of the same type and returns a value indicating whether one object is less than, equal to, or greater than the other.
Returns A signed integer that indicates the relative values of <paramref name="x" /> and <paramref name="y" /> , as shown in the following table.
<list type="table">
<listheader>
<term> Value</term>
<description> Meaning</description>
</listheader>
<item>
<term> Less than zero</term>
<description>
<paramref name="x" /> is less than <paramref name="y" />.</description>
</item>
<item>
<term> Zero</term>
<description>
<paramref name="x" /> equals <paramref name="y" />.</description>
</item>
<item>
<term> Greater than zero</term>
<description>
<paramref name="x" /> is greater than <paramref name="y" />.</description>
</item>
</list>
x
The first object to compare.
y
The second object to compare.
public static
Comparer<​T>
Create​(Comparison<​T> comparison)
Creates a comparer by using the specified comparison.
Returns The new comparer.
comparison
The comparison to use.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object